//
//  YWSquareDetailTableViewCell.m
//  聆听FM
//
//  Created by dllo on 16/6/11.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "YWSquareDetailTableViewCell.h"

@implementation YWSquareDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.numberLabel = [[UILabel alloc] init];
        _numberLabel.font = [UIFont systemFontOfSize:14];
        _numberLabel.textAlignment = 2;
        [self.contentView addSubview:_numberLabel];
        
        self.photoImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_photoImageView];
        
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_titleLabel];
        
        self.nickNameLabel = [[UILabel alloc] init];
        _nickNameLabel.font = [UIFont systemFontOfSize:12];
        _nickNameLabel.textColor = [UIColor colorWithWhite:0.651 alpha:1.000];
        [self.contentView addSubview:_nickNameLabel];
        
        self.iconImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_iconImageView];
        
        self.trackLabel = [[UILabel alloc] init];
        _trackLabel.font = [UIFont systemFontOfSize:12];
        _trackLabel.textColor = [UIColor colorWithWhite:0.651 alpha:1.000];
        [self.contentView addSubview:_trackLabel];
        
        self.arrowImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_arrowImageView];
        
        self.lineLabel = [[UILabel alloc] init];
        _lineLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_lineLabel];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _numberLabel.frame = CGRectMake(0 * FITWIDTH, 32.5 * FITHEIGHT, 30 * FITWIDTH, 15 * FITHEIGHT);
    _photoImageView.frame = CGRectMake(40 * FITWIDTH, 10 * FITHEIGHT, 60 * FITWIDTH, 60 * FITHEIGHT);
    _titleLabel.frame = CGRectMake(_photoImageView.frame.origin.x + _photoImageView.bounds.size.width + 10 * FITWIDTH, _photoImageView.frame.origin.y - 5 * FITHEIGHT, 200 * FITWIDTH, 30 * FITHEIGHT);
    _nickNameLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.bounds.size.height + 5 * FITHEIGHT, 200 * FITWIDTH, 20);
    _iconImageView.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.bounds.size.height + 30 * FITHEIGHT, 12 * FITWIDTH, 12 * FITHEIGHT);
    _trackLabel.frame = CGRectMake(_iconImageView.frame.origin.x + _iconImageView.bounds.size.width + 10 * FITWIDTH, _iconImageView.frame.origin.y - 4 * FITHEIGHT, 100 * FITWIDTH, 20 * FITHEIGHT);
    _arrowImageView.frame = CGRectMake(SCREENWIDTH - 30, 30 * FITHEIGHT, 20 * FITWIDTH, 20 * FITHEIGHT);
    _lineLabel.frame = CGRectMake(100 * FITWIDTH, self.bounds.size.height - 1, SCREENWIDTH - 100 * FITWIDTH, 1);
}

- (void)setSquareModel:(YWSquareModel *)squareModel
{
    if (_squareModel != squareModel) {
        [_photoImageView sd_setImageWithURL:[NSURL URLWithString:squareModel.coverMiddle] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        _titleLabel.text = squareModel.title;
        _nickNameLabel.text = squareModel.nickname;
        _iconImageView.image = [UIImage imageNamed:@"album_tracks"];
        _trackLabel.text = [NSString stringWithFormat:@"%ld集", squareModel.tracksCounts];
        _arrowImageView.image = [UIImage imageNamed:@"向右"];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
